//
//  QZCommentFootView.m
//  shortvideoplay
//
//  Created by tikeios_002 on 2024/6/19.
//

#import "QZCommentFootView.h"

@implementation QZCommentFootView
{
    UIView * footLine;
    UIButton * launch;
    UIButton * putAway;
}
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        footLine = [[UIView alloc]init];
        footLine.backgroundColor = ColorHex_Alpha(@"ffffff", 0.82);
        footLine.layer.cornerRadius = 0.5;
        footLine.clipsToBounds = YES;
        [self addSubview:footLine];
        
        launch = [UIButton new];
        [launch setTitleColor:ColorHex_Alpha(@"ffffff", 0.82) forState:UIControlStateNormal];
        launch.titleLabel.font = FontBold(12);
        launch.tag = 0;
        [launch addTarget:self action:@selector(footTap:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:launch];
        
        putAway = [UIButton new];
        [putAway setTitleColor:ColorHex_Alpha(@"ffffff", 0.82) forState:UIControlStateNormal];
        putAway.titleLabel.font = FontBold(12);
        putAway.tag = 1;
        [putAway addTarget:self action:@selector(footTap:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:putAway];
        
        [launch setTitle:@"展示更多" forState:UIControlStateNormal];
        [putAway setTitle:@"收起" forState:UIControlStateNormal];
        
        [footLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(57);
            make.centerX.mas_offset(20);
            make.height.mas_offset(0.6);
            make.width.mas_offset(20);
        }];
        [launch mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(footLine).mas_offset(10);
            make.top.mas_offset(2);
            make.height.mas_offset(40);
        }];
        [putAway mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(footLine).mas_offset(10);
            make.top.mas_offset(2);
            make.width.mas_equalTo(50);
            make.height.mas_offset(40);
        }];
    UIButton * textShowButtonTo1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        NSString * textShowButtonTitleTo1 = @"测试功能";
        [textShowButtonTo1 setTitle:textShowButtonTitleTo1 forState:UIControlStateNormal];
        NSInteger textShowArcTo1 = arc4random_uniform(22);
        NSLog(@"随机数：%ld", (long)textShowArcTo1);
    }
    return self;
}
- (void)setLaunchStr:(NSString *)launchStr{
    _launchStr = launchStr;
    [launch setTitle:launchStr forState:UIControlStateNormal];
    if(launchStr.length == 0){
        [putAway mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(launch).mas_offset(0);
        }];
    }else{
        [putAway mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(launch).mas_offset(30);
        }];
    }
}
- (void)footTap:(UIButton *)sender{
    self.commentFootTapBlock(sender.tag);
}
- (void)setIsShowputAway:(BOOL)isShowputAway{
    putAway.hidden = isShowputAway;
}
@end
